package com.iniyo.ai.poetry;

import com.baidu.aip.nlp.AipNlp;
import org.json.JSONObject;

import java.util.HashMap;

public class Test {
    //设置APPID/AK/SK
    public static final String APP_ID = "23506433";
    public static final String API_KEY = "gC5wc0AHMwKF6FgmaOj1nhbs";
    public static final String SECRET_KEY = "N45ZIvBHzKjKPxQ9uXyz0xeLfULrjnkK";

    public static void main(String[] args) {
        contentSummary();
    }

    /**
     * 信息摘要
     */
    private static void contentSummary() {
        // 初始化一个AipNlp
        AipNlp client = new AipNlp(APP_ID, API_KEY, SECRET_KEY);
        String content = "麻省理工学院的研究团队为无人机在仓库中使用RFID技术进行库存查找等工作，创造了一种...";
        int maxSummaryLen = 300;

        // 传入可选参数调用接口
        HashMap<String, Object> options = new HashMap<String, Object>();
        options.put("title", "标题");

        // 新闻摘要接口
        JSONObject res = client.newsSummary(content, maxSummaryLen, options);
        System.out.println(res.toString(2));
    }

}
